package goodroommate.domain;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;

public class Questionnaire {

	private long id;
	private String subject;
	private Timestamp starttime;
	private Timestamp endtime;
	private ArrayList<Question> questions;
	private int status;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public Timestamp getStarttime() {
		return starttime;
	}

	public void setStarttime(Timestamp starttime) {
		this.starttime = starttime;
	}

	public Timestamp getEndtime() {
		return endtime;
	}

	public void setEndtime(Timestamp endtime) {
		this.endtime = endtime;
	}

	public ArrayList<Question> getQuestions() {
		return questions;
	}

	public void setQuestions(ArrayList<Question> questions) {
		this.questions = questions;
	}

	public String getStartTimeFormatted() {
		if (this.starttime == null)
			return "";
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		return df.format(this.starttime);
	}

	public String getEndTimeFormatted() {
		if (this.endtime == null)
			return "";
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		return df.format(this.endtime);
	}

	public int getStatus() {
		return status;
	}

	public void setStatus() {

		Timestamp now = new Timestamp(System.currentTimeMillis());
		if (now.before(endtime))
			this.status = 1;
		else
			this.status = 0;
	}

}
